package StudyCode.summary.mycollection;

import java.util.Iterator;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class FillsAnArrayWithTheContentsOfAnIterator {
	public static void fillArray(Iterator ii, Object[] fillMe,
	                             boolean null_terminate) {
		int i = 0;
		int len = fillMe.length;
		while (i < len && ii.hasNext())
			fillMe[i++] = ii.next();
		if (null_terminate && i < len)
			fillMe[i] = null;
	}

	public static void fillArray(Iterator ii, Object[] fillMe) {
		fillArray(ii, fillMe, false);
	}
}
